package controllers

import (
	"exchangeapp/global"
	"github.com/gin-gonic/gin"
	"net/http"
)

func LikeController(ctx *gin.Context) {
	times := "浏览次数"
	if err := global.RedisDB.Incr(times).Err(); err != nil {
		ctx.JSON(http.StatusInternalServerError, gin.H{"error": "内部错误"})
		return
	}
	number, err := global.RedisDB.Get(times).Result()
	if err != nil {
		ctx.JSON(http.StatusInternalServerError, gin.H{"message": "读取错误"})
	}
	ctx.JSON(http.StatusOK, gin.H{
		"message": "成功增加一次浏览量",
		"number":  number,
	})
}
